home *** CD-ROM | disk | FTP | other *** search
- /************************************/
- /* Application: TransitionDemo
- Function: Demonstrates different visual effects. */
- /************************************/
- /* #include file */
- #include "General.h"
- #include "Demo.h"
-
- /* External variables and functions */
- extern void InitMyMenus(void);
- extern void HandleMenu(char *doneFlag, short theMenu, short theItem);
- extern void UpdateMenu();
-
- /* globals variables and function prototypes */
- void main(void);
-
- /************************************/
- /* Routines:
- • void main()
- */
- /************************************/
-
- /************************************/
- /* void main()
- main entry into Transition App */
- /************************************/
- void main()
- {
- char doneFlag;
- char ch;
- short code;
- short theMenu,theItem;
- long mResult;
- WindowPtr whichWindow;
- EventRecord myEvent;
- Rect tempRect;
- GrafPtr SavePort;
-
- /* init Mac stuff */
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- /* init app stuff */
- doneFlag = FALSE;
- InitMyMenus();
- Init_Demo();
-
- /* start transition */
- Open_Demo();
-
- do { /* Main Event Loop */
- SystemTask();
-
- if (GetNextEvent(everyEvent, &myEvent)) { /* got event */
- code = FindWindow(myEvent.where, &whichWindow);
-
- switch (myEvent.what) { /* event switch */
- case mouseDown: /* mouse event */
- if (code == inMenuBar) { /* menu bar */
- UpdateMenu();
- mResult = MenuSelect(myEvent.where);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- HandleMenu(&doneFlag,theMenu,theItem);
- } /* menu bar */
-
- if ((code == inDrag)&&(whichWindow != NIL)) { /* drag bar */
- tempRect = screenBits.bounds;
- SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25,
- tempRect.right - 10, tempRect.bottom - 10);
- DragWindow(whichWindow, myEvent.where, &tempRect);
- } /* drag bar */
-
- if (code == inContent) { /* In a window */
- if (whichWindow != FrontWindow())
- SelectWindow(whichWindow);
- else {
- SetPort(whichWindow);
- Do_Demo (&myEvent);
- }
- } /* In a window */
-
- if (code == inSysWindow) /* In a DA window */
- SystemClick(&myEvent, whichWindow);
- break; /* mouse event */
-
- case keyDown: /* key event */
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey) { /* command key event */
- mResult = MenuKey(ch);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- if (theMenu != 0)
- HandleMenu(&doneFlag, theMenu, theItem);
- }
- break; /* key event */
-
- case updateEvt: /* update event */
- whichWindow = (WindowPtr)myEvent.message;
- GetPort(&SavePort);
- BeginUpdate(whichWindow);
- SetPort(whichWindow);
- UpDate_Demo(whichWindow);
- EndUpdate(whichWindow);
- SetPort(SavePort);
- break; /* update event */
-
- case activateEvt: /* activate event */
- if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag))
- SelectWindow(whichWindow);
- break; /* activate event */
-
- default:
- break;
- } /* event switch */
- } /* got event */
- } while (doneFlag == FALSE); /* Main Event Loop */
- DisposeWindow(MyWindow);
- }
-